home *** CD-ROM | disk | FTP | other *** search
- '\"
- '\" Copyright (c) 1989-1993 The Regents of the University of California.
- '\" Copyright (c) 1994-1995 Sun Microsystems, Inc.
- '\"
- '\" See the file "license.terms" for information on usage and redistribution
- '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
- '\"
- '\" @(#) TildeSubst.3 1.12 95/02/22 14:37:20
- '\"
- .so man.macros
- .HS Tcl_TildeSubst tclc 7.0
- .BS
- .SH NAME
- Tcl_TildeSubst \- replace tilde with home directory in a file name
- .SH SYNOPSIS
- .nf
- \fB#include <tcl.h>\fR
- .sp
- char *
- .VS
- \fBTcl_TildeSubst\fR(\fIinterp\fR, \fIname\fR, \fIbufferPtr)
- .VE
- .SH ARGUMENTS
- .AS Tcl_DString *bufferPtr
- .AP Tcl_Interp *interp in
- Interpreter in which to report an error, if any.
- .AP char *name in
- File name, which may start with a ``~''.
- .AP Tcl_DString *bufferPtr
- .VS
- If needed, this dynamic string is used to store the new file name.
- At the time of the call it should be uninitialized or empty. The
- caller must eventually call \fBTcl_DStringFree\fR to free up
- anything stored here.
- .VE
- .BE
-
- .SH DESCRIPTION
- .PP
- This utility procedure does tilde substitution. If \fIname\fR doesn't
- start with a ``~'' character, then the procedure returns \fIname\fR.
- If \fIname\fR does start with a tilde, then \fBTcl_TildeSubst\fR
- returns a new string identical to \fIname\fR except that the first
- element of \fIname\fR is replaced with the location of the home
- directory for the given user. The substitution is carried out in
- the same way that it would be done by \fIcsh\fR. If the tilde is
- followed immediately by a slash, then the \fB$HOME\fR environment
- variable is substituted. Otherwise the characters between the
- tilde and the next slash are taken as a user name, which is
- looked up in the password file; the user's home directory is
- retrieved from the password file and substituted.
- .PP
- If
- .VS
- \fBTcl_TildeSubst\fR has to do tilde substitution then it uses
- the dynamic string at \fI*bufferPtr\fR to hold the new string it
- generates. After \fBTcl_TildeSubst\fR returns, the caller must
- eventually invoke \fBTcl_DStringFree\fR to free up any information
- placed in \fI*bufferPtr\fR. The caller need not know whether or
- not \fBTcl_TildeSubst\fR actually used the string; \fBTcl_TildeSubst\fR
- initializes \fI*bufferPtr\fR even if it doesn't use it, so the call to
- \fBTcl_DStringFree\fR will be safe in either case.
- .VE
- .PP
- If an error occurs (e.g. because there was no user by the given
- name) then NULL is returned and an error message will be left
- at \fIinterp->result\fR. It is assumed that \fIinterp->result\fR
- has been initialized in the standard way when \fBTcl_TildeSubst\fR
- is invoked.
-
- .SH KEYWORDS
- file name, home directory, tilde, user
-